<?php
declare(strict_types = 1);

namespace app\member\controller;

use app\common\controller\MemberBase;
use app\common\wormview\AddEditList;

class Sms extends MemberBase
{
    use AddEditList;
    protected function initialize(){
        parent::initialize();
        $model = "app\\common\\model\\Sms";
        $this->model = new $model;
        $this->list_temp = ':sms_list';
    }
    protected function getMap()
    {
        $map = [
            'to_uid' => $this->wormuser['uid'],
            'status' => !isset($this->getdata['status']) ? 'a' : $this->getdata['status'],
        ];
        return array_merge(parent::getMap(),$map); // TODO: Change the autogenerated stub
    }
    public function read($id)
    {
        $this->list_temp = $this->hasview("sms_read.htm");
        if(!is_file($this->list_temp)){
            $this->error("模板文件【{$this->list_temp}】不存在");
        }
        $_old = $this->model->getOne($id);
        if($_old['status'] != '1'){
            $_add = [
                'id' => $_old['id'],
                'status' => '1',
                'endtime' => time()
            ];
            $this->model->setOne($_add);
        }
        return $this->viewMemberRead($_old);
    }
}